#=========================================
#     FileName: utils.py
#         Desc:
#       Author: ez~
#        Email: 2511384642@qq.com
#     HomePage: 
#      Version: 0.0.1
#   LastChange: 2021-08-04 19:53:22
#      Descrip:
#
#      工具函数定义
#=========================================
from config import *
import requests, json


def push(data):
    """向服务器推送数据

    :type parma data: dict
    :rtype: int
    
    """
 
    url = "http://" + SERVER_IP + ":" + str(SERVER_PORT) + DATA_PUSH

    try:
        res = requests.post(url, json.dumps(data))
    except:
        print("数据推送失败")

    return res.status_code


if __name__ == '__main__':

    # utils工具函数测试
    data = {
        "temu": 10,
        "humi": 12
    }
    print(push(data))


